using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    /// <summary>
    /// 进出物理区域触发器
    /// 参数：是否离开（1离开区域，0进入区域）
    /// </summary>
    public class TrigEnterOrLeaveSpeRoom : BaseServiceTrigger
    {
        private bool isOut;

        public override void Init(BaseServiceTriggerConfig paramConfig)
        {
            base.Init(paramConfig);
            var config = _paramConfig as TrigParamSwitchPhysicalArea;
            if (config == null || (config.type != 1 && config.type != 2))
            {
                LogicLog.LogError($"触发器[{nameof(TrigEnterOrLeaveSpeRoom)}]参数错误。type: {config.type}");
                return;
            }
            isOut = config.isOut;
        }

        public override bool OnTrigger(LevelPlayer player, object objParam, TrigValueTypeParam valueTypePram)
        {
            if ((valueTypePram.param1 == 1) == isOut)
            {
                return base.OnTrigger(player, objParam, valueTypePram);
            }
            return false;
        }
    }
}
